<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>查看</title>
    <link href="plugin/date/date.css" rel="stylesheet">
    <link href="bootstrap/css/bootstrap3.min.css" rel="stylesheet">
    <link href="https://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
    <link rel="stylesheet" href="css/nav.css" />
</head>

<body>
    <!--导航-->
    <nav class="navbar navbar-inverse">
        <div class="container-fluid">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-2">
              <span class="sr-only">Toggle navigation</span>
              <span class="icon-bar"></span>
              <span class="icon-bar"></span>
              <span class="icon-bar"></span>
            </button>
                <a class="navbar-brand" href=""><img src="images/admin_logo.png" alt=""></a>
            </div>

            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-2">
                <ul class="nav navbar-nav" id="nav">

                </ul>
                <ul class="nav navbar-nav navbar-right">
                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">欢迎您：<span id="uname"></span><span class="caret"></span></a>
                        <ul class="dropdown-menu" role="menu">
                            <li><a href="change_pass.html">修改密码</a></li>
                            <li><a id="loginOut" href="#">退出登陆</a></li>
                        </ul>
                    </li>
                </ul>
            </div>
        </div>
    </nav>
    <div class="container-fluid">
        <div class="row bcert-box">
            <ol class="breadcrumb">
                <li><a href="javascript:;">主页</a></li>
                <li>店铺管理</li>
                <li class="active">店铺管理</li>
            </ol>
            <div class="col-md-8">
                <table class="table table-bordered" id="integralList">

                </table>
            </div>
        </div>
    </div>

    <!-- 编辑 -->
    <div class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" id="entinfo">
        <div class="modal-dialog modal-lg" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
                    <h4 class="modal-title" id="myLargeModalLabel">编辑</h4>
                </div>
                <div class="modal-body" style="overflow:auto">
                    <div class="form-group">
                        <label class="col-sm-4 control-label goods-lb-l">id</label>
                        <div class="col-sm-8 goods-lb-r"><input type="text" readonly="readonly" class="form-control" id="partner_id" placeholder="id"></div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label goods-lb-l">合作方名称</label>
                        <div class="col-sm-8 goods-lb-r"><input type="text" readonly="readonly" class="form-control" id="partner_name" placeholder="合作方等级名称"></div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label goods-lb-l">金牌小卫士每月新增数量（人）</label>
                        <div class="col-sm-8 goods-lb-r"><input type="text" class="form-control" id="quantity" placeholder="金牌小卫士每月新增数量"></div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label goods-lb-l">营收（元）</label>
                        <div class="col-sm-8 goods-lb-r"><input type="text" class="form-control" id="revenue" placeholder="营收"></div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label goods-lb-l">完成业绩分成比例（%）</label>
                        <div class="col-sm-8 goods-lb-r"><input type="text" class="form-control" id="complete_reward" placeholder="完成业绩分成比例"></div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label goods-lb-l">未完成业绩分成比例（%）</label>
                        <div class="col-sm-8 goods-lb-r"><input type="text" class="form-control" id="unfinished_bonus" placeholder="未完成业绩分成比例"></div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    <button type="button" class="btn btn-primary" id="entBtn">确认提交</button>
                </div>
            </div>
            <!-- /.modal-content -->
        </div>
    </div>
</body>
<script src="js/jquery.min.js"></script>
<!-- <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script> -->
<script type="text/javascript" src="plugin/layer/layer.js"></script>
<script type="text/javascript" src="js/cookie.js"></script>
<script type="text/javascript" src="js/common.js"></script>
<script src="./js/jquery.cookie.js" charset="utf-8"></script>
<script type="text/javascript" src="./js/ajax.js" charset="utf-8"></script>
<script type="text/javascript" src="bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/bootstrap-paginator.js"></script>
<script type="text/javascript" src="plugin/date/date.js"></script>
<script type="text/javascript" src="plugin/date/date.zh-CN.js"></script>

<script>
    function UrlSearch() {
        var name, value;
        var str = location.href; //取得整个地址栏;
        var num = str.indexOf("?")
        str = str.substr(num + 1); //取得所有参数   stringvar.substr(start [, length ]

        var arr = str.split("&"); //各个参数放到数组里
        for (var i = 0; i < arr.length; i++) {
            num = arr[i].indexOf("=");
            if (num > 0) {
                name = arr[i].substring(0, num);
                value = arr[i].substr(num + 1);
                this[name] = value;
            }
        }
    }
    var Request = new UrlSearch(); //实例化
    var storeId = Request.id;
    console.log(storeId);
    $.cookie('cokstoreId',storeId,{ expires: 7});
    var cokstoreId = $.cookie('cokstoreId');
    console.log(cokstoreId);

    // console.log(storeId);
    // var serverURL = 'http://ww.wuyoutianxia.com/wy3pt';
    $("document").ready(function() {
        tableList()
    })

    var pageUrls = serverURL + '/platform/queryStoreById';

    function tableList() {
        data = {
            // 'member':$('#member').val(),
            // 'memberType':$('#memberType').val(),
            // 'inviterId':$('#inviterId').val(),
            // 'memberState':$('#memberState').val(),
            // 'startTime':$('#startTime').val(),
            // 'endTime':$('#endTime').val(),
            'storeId': storeId,
            'page': page,
            'pageSize': pagesize
        }
        data.page = 1
        ajax(
            pageUrls,
            data,
            OpendList,
            'post',
            'json'
        )
    }

    $('#entinfo').on('hidden.bs.modal', function(e) {
        $('.modal-body input').val(null);
    })

    //数据渲染
    function OpendList(integralList) {
        var result = '';
        var integralList = integralList.data
        $('#integralList').empty();
        // $('#integralList').append(
        //     '<tr>' +
        //     '<th>店铺</th>' +
        //     '<th>店主账号</th>' +
        //     '<th>店主卖家账号</th>' +
        //     '<th>所属等级</th>' +
        //     '<th>有效期至</th>' +
        //     '<th>状态</th>' +
        //     '<th>操作</th>' +
        //     '</tr>'
        // );
        result +=
            '<thead>' +
            '<tr rowspan="1" class="active">' +
            '<th colspan="6">公司及联系人信息</th>' +
            '</tr>' +
            '</thead>' +
            '<tbody>' +
            '<tr><td>公司名称：</td><td colspan="5">' + integralList.companyName + '</td></tr>' +
            '<tr><td>公司所在地：</td><td>' + integralList.companyProvinceId + '</td><td>公司详细地址：</td><td colspan="3">' + integralList.companyAddress + '</td></tr>' +
            '<tr><td>公司电话：</td><td>' + integralList.companyPhone + '</td><td>员工总数：</td><td>' + integralList.companyEmployeeCount + '</td><td>注册资金：</td><td>' + integralList.companyRegisteredCapital + '</td></tr>' +
            '<tr><td>联系人姓名：</td><td>' + integralList.contactsName + '</td><td>联系人电话：</td><td>' + integralList.contactsPhone + '</td><td>电子邮箱：</td><td>' + integralList.contactsEmail + '</td></tr>' +
            '</tbody>'

        result +=
            '<thead>' +
            '<tr rowspan="1" class="active">' +
            '<th colspan="6">营业执照信息（副本）</th>' +
            '</tr>' +
            '</thead>' +
            '<tbody>' +
            '<tr><td>营业执照号：</td><td colspan="5">' + integralList.businessLicenceNumber + '</td></tr>' +
            '<tr><td>营业执照所在地：</td><td colspan="5">' + integralList.businessLicenceAddress + '</td></tr>' +
            '<tr><td>营业执照有效期：</td><td colspan="5">' + integralList.businessLicenceStart + '</td></tr>' +
            '<tr><td>法定经营范围：</td><td colspan="5">' + integralList.businessSphere + '</td></tr>' +
            '<tr><td>营业执照电子版：</td><td colspan="5"><img src="http://axyhpic.oss-cn-zhangjiakou.aliyuncs.com/' + integralList.businessLicenceNumberElectronic + '" alt="营业执照电子版" width="300" /></td></tr>' +
            '</tbody>'

        result +=
            '<thead>' +
            '<tr rowspan="1" class="active">' +
            '<th colspan="6">组织机构代码证</th>' +
            '</tr>' +
            '</thead>' +
            '<tbody>' +
            '<tr><td>组织机构代码：</td><td colspan="5">sdfsdf</td></tr>' +
            '<tr><td>组织机构代码证电子版：</td><td colspan="5"><img src="http://axyhpic.oss-cn-zhangjiakou.aliyuncs.com/' + integralList.organizationCodeElectronic + '" alt="组织机构代码证电子版" width="300" /></td></tr>' +
            '</tbody>'

        result +=
            '<thead>' +
            '<tr rowspan="1" class="active">' +
            '<th colspan="6">一般纳税人证明</th>' +
            '</tr>' +
            '</thead>' +
            '<tbody>' +
            '<tr><td>一般纳税人证明：</td><td colspan="5"><img src="http://axyhpic.oss-cn-zhangjiakou.aliyuncs.com/' + integralList.generalTaxpayer + '" alt="一般纳税人证明" width="300" /></td></tr>' +
            '</tbody>'

        result +=
            '<thead>' +
            '<tr rowspan="1" class="active">' +
            '<th colspan="6">开户银行信息</th>' +
            '</tr>' +
            '</thead>' +
            '<tbody>' +
            '<tr><td>银行开户名：</td><td colspan="5">' + integralList.bankAccountName + '</td></tr>' +
            '<tr><td>公司银行账号：</td><td colspan="5">' + integralList.bankAccountNumber + '</td></tr>' +
            '<tr><td>开户银行支行名称：</td><td colspan="5">' + integralList.bankName + '</td></tr>' +
            '<tr><td>支行联行号：</td><td colspan="5">' + integralList.bankCode + '</td></tr>' +
            '<tr><td>开户银行所在地：</td><td colspan="5">' + integralList.bankAddress + '</td></tr>' +
            '<tr><td>开户银行许可证电子版：</td><td colspan="5"><img src="http://axyhpic.oss-cn-zhangjiakou.aliyuncs.com/' + integralList.bankLicenceElectronic + '" alt="开户银行许可证电子版" width="300" /></td></tr>' +
            '</tbody>'

        result +=
            '<thead>' +
            '<tr rowspan="1" class="active">' +
            '<th colspan="6">结算账号信息</th>' +
            '</tr>' +
            '</thead>' +
            '<tbody>' +
            '<tr><td>银行开户名：</td><td colspan="5">' + integralList.bankAccountName + '</td></tr>' +
            '<tr><td>公司银行账号：</td><td colspan="5">' + integralList.bankAccountNumber + '</td></tr>' +
            '<tr><td>开户银行支行名称：</td><td colspan="5">' + integralList.bankName + '</td></tr>' +
            '<tr><td>支行联行号：</td><td colspan="5">' + integralList.bankCode + '</td></tr>' +
            '<tr><td>开户银行所在地：</td><td colspan="5">' + integralList.bankAddress + '</td></tr>' +
            '</tbody>'

        result +=
            '<thead>' +
            '<tr rowspan="1" class="active">' +
            '<th colspan="6">税务登记证</th>' +
            '</tr>' +
            '</thead>' +
            '<tbody>' +
            '<tr><td>税务登记证号：</td><td colspan="5">' + integralList.taxRegistrationCertificate + '</td></tr>' +
            '<tr><td>纳税人识别号：</td><td colspan="5">' + integralList.taxpayerId + '</td></tr>' +
            '<tr><td>税务登记证号电子版：</td><td colspan="5"><img src="http://axyhpic.oss-cn-zhangjiakou.aliyuncs.com/' + integralList.taxRegistrationCertificateElectronic + '" alt="" width="300" /></td></tr>' +
            '</tbody>'

        result +=
            '<thead>' +
            '<tr rowspan="1" class="active">' +
            '<th colspan="6">店铺经营信息</th>' +
            '</tr>' +
            '</thead>' +
            '<tbody>' +
            '<tr><td>卖家账号：</td><td colspan="5">' + integralList.memberMobile + '</td></tr>' +
            '<tr><td>店铺名称：</td><td colspan="5">' + integralList.storeName + '</td></tr>' +
            '<tr><td>店铺等级：</td><td colspan="5">' + integralList.sgName + '</td></tr>' +
            '<tr><td>开店时长：</td><td colspan="5">' + integralList.openedTime + '</td></tr>' +
            '<tr><td>店铺分类：</td><td colspan="5">' + integralList.scName + '</td></tr>' +
            '<tr><td>应付总金额：</td><td colspan="5">' + integralList.amountOfPay + '</td></tr>' +
            '<tr><td>经营类目：</td><td colspan="5"><table class="table table-bordered" style="margin-bottom:0">'+
            '<tr class="active"><th>分类一</th><th>分类二</th><th>分类三</th><th>比例</th></tr>';
                for(n in integralList.gradeManage){
                    result += '<tr><td>'+integralList.gradeManage[n].class1+'</td><td>'+integralList.gradeManage[n].class2+'</td><td>'+integralList.gradeManage[n].class3+'</td><td>'+integralList.gradeManage[n].commisRate+'%</td></tr>'
                }
            result +=
            '</table></td></tr>' +
            '<tr><td>付款凭证：</td><td colspan="5">' + integralList.payingMoneyCertificate + '</td></tr>' +
            '<tr><td>付款凭证说明：</td><td colspan="5">' + integralList.payingMoneyCertificateExplain + '</td></tr>' +
            '</tbody>'
        // for (var i = 0; i < integralList.list.length; i++) {
        //     var time = getMyDate(integralList.list[i].createTime);
        //         '<tr>' +
        //         '<td>' + integralList.list[i].partner_name + '</td>' +
        //         '<td>' + integralList.list[i].quantity + '</td>' +
        //         '<td>' + integralList.list[i].revenue + '</td>' +
        //         '<td>' + integralList.list[i].complete_reward + '</td>' +
        //         '<td>' + integralList.list[i].unfinished_bonus + '</td>' +
        //         '<td>' + integralList.list[i].unfinished_bonus + '</td>' +
        //         '<td class="text-center">' +
        //         '<button type="button" data-id="' + integralList.list[i].partner_id + '" class="btn btn-primary btn-sm listEnt" data-toggle="modal" data-target=".bs-example-modal-lg">查看</button>&nbsp;&nbsp;' +
        //         '<button type="button" data-id="' + integralList.list[i].partner_id + '" class="btn btn-primary btn-sm listEnt" data-toggle="modal" data-target=".bs-example-modal-lg">编辑</button>&nbsp;&nbsp;' +
        //         '<button type="button" data-id="' + integralList.list[i].partner_id + '" class="btn btn-primary btn-sm listEnt" data-toggle="modal" data-target=".bs-example-modal-lg">经营类目</button>&nbsp;&nbsp;' +
        //         '<button type="button" data-id="' + integralList.list[i].partner_id + '" class="btn btn-danger btn-sm listEnt" data-toggle="modal" data-target=".bs-example-modal-lg">删除</button>&nbsp;&nbsp;' +
        //         '</td>' +
        //         '</tr>'
        // }
        $('#integralList').append(result)
    }
    //删除
    $(document).on('click', '.listDel', function() {
        var id = $(this).attr('data-id')
        layer.confirm('确定要删除这条信息吗？', {
            btn: ['确定', '取消'] //按钮
        }, function() {
            deleteList(id)
        }, function() {});
    })
    //详情
    $(document).on('click', '.listEnt', function() {
        var id = $(this).attr('data-id')
        $.ajax({
            url: serverURL + '/member/queryPartnerLevelByPrimaryKey',
            type: "post",
            dataType: "json",
            data: {
                'partner_id': id,
            },
            success: function(data) {
                console.log(data.msg)
                if (data.code == 400) {
                    alert("登陆超时请重新登陆")
                    window.location.href = "login.html";
                } else if (data.code == 200) {
                    $('#partner_id').val(data.data.partner_id)
                    $('#partner_name').val(data.data.partner_name)
                    $('#quantity').val(data.data.quantity)
                    $('#revenue').val(data.data.revenue)
                    $('#complete_reward').val(data.data.complete_reward)
                    $('#unfinished_bonus').val(data.data.unfinished_bonus)
                    integralListPaga();
                }
            }
        });
    })

    //修改
    $('#entBtn').click(function() {
        $.ajax({
            url: serverURL + '/member/savePartnerLevel',
            type: "post",
            dataType: "json",
            data: {
                'partner_id': $('#partner_id').val(),
                'partner_name': $('#partner_name').val(),
                'quantity': $('#quantity').val(),
                'revenue': $('#revenue').val(),
                'complete_reward': $('#complete_reward').val(),
                'unfinished_bonus': $('#unfinished_bonus').val()
            },
            success: function(data) {
                console.log(data.msg)
                layer.msg(data.msg)
                if (data.code == 400) {
                    alert("登陆超时请重新登陆")
                    window.location.href = "login.html";
                } else if (data.code == 200) {
                    $('#entinfo').modal('hide')
                    integralListPaga();
                }
            }
        });
    })

    //删除
    function deleteList(id) {
        $.ajax({
            url: serverURL + '/member/delPartnerLevel',
            type: "post",
            dataType: "json",
            data: {
                'ids': id,
            },
            success: function(data) {
                console.log(data.msg)
                layer.msg(data.msg)
                if (data.code == 400) {
                    alert("登陆超时请重新登陆")
                    window.location.href = "login.html";
                } else if (data.code == 200) {
                    integralListPaga();
                }
            }
        });
    }
</script>

</html>
